home *** CD-ROM | disk | FTP | other *** search
/ Java Primer Plus / Java Primer Plus (Waite Group Proess)(1996).iso / java_Win / demo / ImageMap / ClickArea.class (.txt) < prev    next >
Encoding:
Java Class File  |  1995-10-12  |  1.7 KB  |  35 lines

  1. import java.awt.Graphics;
  2.  
  3. class ClickArea extends ImageMapArea {
  4.    int startx;
  5.    int starty;
  6.  
  7.    public void handleArg(String arg) {
  8.       super.terminal = false;
  9.    }
  10.  
  11.    public void highlight(Graphics g, boolean on) {
  12.    }
  13.  
  14.    String ptstr(int x, int y) {
  15.       return "(" + x + ", " + y + ")";
  16.    }
  17.  
  18.    public void press(int x, int y) {
  19.       ((ImageMapArea)this).showStatus("Clicked at " + this.ptstr(x, y));
  20.       this.startx = x;
  21.       this.starty = y;
  22.    }
  23.  
  24.    public void drag(int x, int y) {
  25.       ((ImageMapArea)this).showStatus("Rectangle from " + this.ptstr(this.startx, this.starty) + " to " + this.ptstr(x, y) + " is " + (x - this.startx) + "x" + (y - this.starty));
  26.    }
  27.  
  28.    public void lift(int x, int y) {
  29.       this.drag(x, y);
  30.    }
  31.  
  32.    public ClickArea() {
  33.    }
  34. }
  35.